
cc.Class({
    extends: require('wy-WeChat'),

    init() {
        this._super();
        this.os = 'swan'
        this.isBaidu = true
        this.isWechat = false;
    },
    login(cb) {
        swan.login({
            success: (res) => {
                console.log('百度登陆成功')
                var systemInfo = wx.getSystemInfoSync();
                var width = 194;
                var height = 55;
                var left = systemInfo.screenWidth / 2 - width / 2;
                var top = 0.84 * systemInfo.screenHeight - height / 2;
                !this.btnLogin || this.btnLogin.destroy();
                this.btnLogin = wx.createUserInfoButton({
                    type: "image",
                    image: "https://oss.073c.com/paopao/image/btn_weixin.png",
                    style: { left: left, top: top, width: width, height: height },
                    withCredentials: true
                });
                this.btnLogin.onTap((data) => {
                    if (!data.iv) return;
                    wx.hideLoading();
                    wx.showLoading({ title: '登录中', mask: true });
                    var obj = { code: res.code, iv: data.iv, encryptedData: data.data, signature: data.signature };
                    Object.assign(obj, data.userInfo)
                    cb(obj);
                });
                this.btnLogin.show();
            },
            fail: function (err) {
                console.log('百度登陆失败:', err);
            }
        });
    },
    createBanner(options) {
        options.appSid = 'a133357d';
        return wx.createBannerAd(options);
    },
    createRewardedVideoAd(options) {
        options.appSid = 'a133357d';
        return wx.createRewardedVideoAd(options);
    },
});

// module.exports = BaiDu;